<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script src="../身份证信息识别/js/jquery-1.11.0.js"></script>
		<script type="text/javascript">
			 $.ajax({
					 type: "GET",
					 url: "http://localhost:8084/aplanmis-mall/rest/region/tree",
					 data: {username:$("#username").val(), content:$("#content").val()},
					 dataType: "json",
					 success: function(res){
						console.log('result',findParents(res.content,"330326"))
					  }
				 });
				function findParents(treeData,code){
				  if(treeData.length==0) return
				  for(let i=0;i<treeData.length;i++){
					if(treeData[i].code == code){
					  return [code]
					}else{
					  if(treeData[i].children){
						let res = findParents(treeData[i].children,code)
						if(res !== undefined){
						  return res.concat(treeData[i].code)
						}
					  }
					}
				  }  
				}
		</script>
	</body>
</html>
